<template>
	<view>
		<scroll-view scroll-x class="bg-white nav">
				<view class="main">
					<view class="main-box">
						<form>
							<view class="cg-main">
								<view class="sticky">
									<view class="cu-form-group" @tap="open('QS_Picekr_date',0)">
										<view class="title">单据日期：　{{timeData.fulldate}}</view>
										<!-- <view @click="open(1)" class="inpt1">
											<input disabled="true">{{timeData.fulldate}}</input>
										</view> --> 
									</view>
									<view class="cu-form-group"　@tap="open('QS_Picekr_date',1)">
										<view class="title">结束日期：　{{timeData1.fulldate}}</view>
										<!-- <view @click="open(2)" class="inpt1">
											<input disabled="true">{{timeData1.fulldate}}</input>
										</view> -->
									</view>
									<view class="cu-form-group">
										<view class="title">单据编号：</view>
										<input class="inpt" placeholder="请输入单据编号"  name="input"  v-model="BillNo" ></input>
									</view>
									<view class="cu-form-group" @click="supplier">
										<view class="title" >供 应 商 ：</view>
										<input :value="checkedClientList.ClientName" disabled="true" placeholder="点击选择<供应商>">
										 <!-- <view class="supplieruser">{{checkedClientList.ClientName}}</view> -->
									</view>
									<view class="cu-form-group" @click="clickopen(2,'仓库')">
										<view class="title">仓　　库：</view>
										<input :value="checkedwarehouse.StoreName" disabled="true" placeholder="点击选择<仓库>">
										<!-- <view class="supplieruser">{{checkedwarehouse.StoreName}}</view> -->
									</view>
									
									<view class="cu-form-group" @click="clickopen(3,'业务员')">
										<view class="title">业 务 员 ：</view>
										<input :value="checksalesman.OperatorName" placeholder="点击选择<业务员>" disabled="true">
										<!-- <view class="supplieruser">{{checksalesman.OperatorName}}</view> -->
									</view>
									
									<!-- <view class="cu-form-group"> -->
										<!-- <view class="uni-padding-wrap"> -->
										           <!-- <view class="uni-title">默认样式</view> -->
										   <!-- <view> -->
											<!-- <label class="radio"><radio value="r1" @click="ischecka" :checked="ischeckall" />全选</label> -->
											<!-- <radio-group @change="radioChange"> -->
										    <!-- <label class="radio"><radio value="r2"   checked="true"/>在线数据</label> -->
										    <!-- <label class="radio"><radio value="r3"  disabled="true" />离线数据</label> -->
											<!-- </radio-group> -->
										    <!-- </view> -->
										   <!-- </view> -->
									<!-- </view> -->
								</view>
		                        <view>
								</view>
                                     <!-- :class="{'setfixed':setfixeds==true}" -->
									<view class="cu-form-group" >
										<button class="cu-btn  stop text-white btn_width" @click="SelBill">查询</button>
										<!-- <input class="inpt" name="input" disabled="true"></input> -->
										<!-- <button class="cu-btn  stop text-white btn_width btn_color" @click="addSelectGoods">上传</button> -->
										<button class="cu-btn   text-white btn_width btn_color" @click="DelectGoods">删除</button>
										<button class="cu-btn  stop text-white btn_width" @click="electGoods">选择</button>
										<!-- <button class="cu-btn  stop text-white btn_width" @click="toDetail()">选择</button> -->
										<button class="cu-btn  stop text-white btn_width" @click="selectcheck">全选</button>
										<!-- elect -->
									</view>
									<!-- <view class="cu-form-group"> -->
					
										<!-- <button class="cu-btn  stop text-white btn_width" @click="swits()">切换</button> -->
										<!-- elect -->
									<!-- </view> -->
								<!--商品明细列表-->
								<view class="selectGoodsList" v-for="(item,index) in OrderGoodsList" :key="index">
		                            <view class="goodListItem" :class="selectLookMore == index?'goodListItem lookMore':''">
										<view class="goodsTitle">{{item.GoodsName}}<button @click="lookGoodsInfo(index)">查看更多</button></view>
										<view class="goods-itemWrap">
											<text class="good-item">
												编号:{{item.GoodsCode}}
											</text>
										</view>
										<view class="goods-itemWrap">
											<text class="good-item">单价:{{item.PFPrice}}</text>
											<text class="good-item">单位:{{item.UnitName}}</text>
										</view>
										<view class="goods-itemWrap">
											<text class="good-item">数量:{{item.Qty}}</text>
											<text class="good-item">库存:{{item.GoodsStorm}}</text>
										</view>
										<view class="goods-itemWrap">
											<text class="good-item">折扣价:{{item.Discount}}</text>
										</view>
										<view class="goods-itemWrap">
											<text class="good-item">备注:{{item.Remark}}</text>
										</view>
									</view>
								</view>
							</view>

						</form>
					</view>
				</view>
				
				<!-- 表格home -->
				<view class="orderList" :style="{height: orderListHeight + 'px'}" v-show="switrs == 1">
					<view class="orderNav" :style="{width:tdAllWidth+'px'}">
										
										
						<text :style="{width:tdWidth[0]+'px'}">序号</text>
						<text :style="{width:tdWidth[1]+'px'}">选择</text>
						<text :style="{width:tdWidth[2]+'px'}">单号</text>
						<text :style="{width:tdWidth[3]+'px'}">日期</text>
						<text :style="{width:tdWidth[4]+'px'}">供货单位</text>
						<text :style="{width:tdWidth[5]+'px'}">仓库</text>
						<text :style="{width:tdWidth[6]+'px'}" >业务员</text>
						<text :style="{width:tdWidth[7]+'px'}" >备注</text>
						
						
					</view>
					<view class="orderLi" :style="{height:orderLiHeight +'px',width:tdAllWidth+'px'}">
						<view class="orderItem" v-for="(item,index) in tableList"  
										 :class="[{'background':!(index%2==0)}]"  :key="index" @click="checktr(index)">
							<view :style="{width:tdWidth[0]+'px'}">{{index+1}}</view>
							<view :style="{width:tdWidth[1]+'px'}">
								<radio  :checked="item.ischeck" @click.stop="radiocheck(index)" />
							</view>
							<view :style="{width:tdWidth[2]+'px'}">{{item.BillNo}}</view>
							<view :style="{width:tdWidth[3]+'px'}">{{item.BillTime}}</view>
							<view :style="{width:tdWidth[4]+'px'}">{{item.BName}}</view>
							<view :style="{width:tdWidth[5]+'px'}">{{item.stockName}}</view>
							<view :style="{width:tdWidth[6]+'px'}">{{item.EName}}</view>
							<view :style="{width:tdWidth[7]+'px'}">{{item.Comment}}</view>
							
						</view>
					</view>
				</view>
<!-- 				<view style="width: 100%;" v-if="tableList !=''"  v-show="switrs == 1">
					<scroll-view scroll-x>
					
				   
					<table border="1" class="table_list" >
					  <tr>
					    <th>序号</th>
					    <th>选择</th>
						<th>单号</th>
						<th>日期</th>
						<th>供货单位</th>
						<th>仓库</th>
						<th>业务员</th>
						<th>备注</th>
					  </tr>
					 
					  <tr v-for="(item,index) in tableList" :key="item.id" @click="checktr(index)">
					    <td>{{ index+1 }}</td>
						<td><radio  :checked="item.ischeck" @click.stop="radiocheck(index)" /></td>
						<td>{{ item.BillNo }}</td>
						<td>{{ timesubstr(item.BillTime) }}</td>
						<td>{{ item.BName }}</td>
						<td>{{ item.stockName }}</td>
						<td>{{ item.EName }}</td>
						<td>{{ item.Comment }}</td>
					  </tr>
					
					</table>
						  
				        </scroll-view>
				</view> -->
				<view class="box_list"  style="background-color: #EEEEEE;" v-show="switrs == 2">
					<view v-for="(item,index) in tableList" :key="item.id" @click="checktr(index)"   :class="['item_list',{'item_table':index == homeunfold}] "  >
						<p>单号：{{ item.BillNo }} <span style="position: absolute;right: 10px;top: 5px;">
						<radio  :checked="item.ischeck" @click.stop="radiocheck(index)" /></span></p>
						
						<p>日期：{{timesubstr(item.BillTime)}}</p>
						<p>供货单位：{{ item.BName }}</p>
						<p>仓库：{{ item.stockName }}</p>
						<p>业务员：{{ item.EName }}</p>
						<p>备注：{{ item.Comment }}</p>
						<div class="radius" @click.stop="homeunfolds(index)">
							<!-- <div class="d3" v-if="index != homeunfold"></div>
							<div class="d4" v-else></div> -->
							<span v-if="index != homeunfold">展开</span>
							<span v-else>收起</span>
						</div>
					</view>
				</view>
				<!-- 表格end -->
			</scroll-view>

			<QSpicker title="请选择日期时间" mode="bottom" type="date" ref="QS_Picekr_date" pickerId="date_1" :dataSet="dateSet"
			 showReset :autoHide="false" contentColor="#33cc33" :lineHeight=".05" @hideQSPicker="hideQSPicker($event)"
			 @showQSPicker="showQSPicker($event)" @confirm="confirm($event)" />

			
			<!-- 统一弹出框HOME -->
			<view class="cu-modal cu_none " :class="modalName=='Modal'?'show':''">
				<view class="cu-dialog"  >
					<view class="cu-bar bg-white justify-end">
						<view class="content">选择{{listcode}}</view>
						<view class="action" @tap="hideModal">
							<text class="cuIcon-close text-red"></text>
						</view>
					</view>
					
					<view style="padding: 5px 21px;">
				
					<view class="search" v-show="listshow == 2"><input class="inpt" v-model="selectwar" placeholder="查询仓库" name="input"></input>
					<span class="search_span"  @click="selectwarehouse()">搜索</span>
					</view>
					
					<view class="search" v-show="listshow == 3"><input class="inpt" v-model="selectsal" placeholder="查询业务员" name="input"></input>
					<span class="search_span" @click="selectsalesmant()">搜索</span>
					</view>
			
					
					</view>
					<scroll-view style="height: 77%;" scroll-y="true">
						
					<view class="padding-xl" v-show="listshow == 2">
						
						<view>
							<view class="btn_list"  v-for="(item,index) in StoreList" 
							 @click="checkware(index)" :key="item.id">{{item.StoreName}}</view>			
						</view>
					</view>
					<view class="padding-xl" v-show="listshow == 3">
						
						<view>
							<view class="btn_list"  v-for="(item,index) in OperatorList" 
							 @click="checksale(index)" :key="item.id">{{item.OperatorName}}</view>			
						</view>
					</view>
					</scroll-view>
				</view>
			</view>
			<!-- 统一弹出框 -->
			<view class="clickscrolltop" v-show="istop" @click="clicktop">返回</br>顶部</view>
	</view>
	
</template>

<script>
	import allConst from "../../../Json.js"
	import uniIcon from '@/components/uni-icon/uni-icon.vue';
	import QSpicker from '@/components/QuShe-picker/QuShe-picker.vue';
	import * as GetApi from '@/syApis/syHttp/Http.js';
	export default {
		data() {
			return {
				
				date: '',
				delbillid:[],//存放删除的id
                selectcheckall:1,// 全选
				isshow:false,//弹出框是否显示
				checklist:-1,
				unfold:-1,// 展开
				homeunfold:-1,// 展开
				switrs:2, //主界面风格切换
				// 选中的供应商
				checkedClientList:[],
				//选中的仓库
				checkedwarehouse:[],
				//选中的业务员
				checksalesman:[],
				listshow:-1,//弹出框显示的内容
				listcode:'',//弹出框显示的title
				timeData: {
					clockinfo: '',
					date: '',
					fulldate: '',
					lunar: '',
					month: '',
					range: '',
					year: ''
				},
				timeData1: {
					fulldate: '',
				},
				isdata:0,//判断是开始日期还是结束日期
				scrollLeft: 0,
				modalName: '',
				unitselected: '',
				BillNo:"",
				//单据类型
				BillType:3,
				IsAdd:0,
				BillDate:"",
				//订单商品
				OrderGoodsList:[],
				//当前选择的商品
				NowSelectGoods:{},
				//商品数量
				GoodsQty:"",
				//商品折扣
				GoodsDiscount:"",
				//商品备注
				GoodsRemark:"",
				//商品库存
				GoodsStorm:"",
				//仓库的列表
				StoreList:[],
				//业务员的列表
				OperatorList:[],
				//供应商的列表
				ClientList:[],
				//制单人
				CreateName:uni.getStorageSync("UserName"),
				//税率
				Tax:"",
				//商品列表查看更多标识
				selectLookMore:-1,
				tableList: [],
				istop:false,
				setfixeds:false,
				selectwar:'',// 搜索的仓库
				selectsal:'',// 搜索的业务员
				dateSet: {
					dateMode: 3,
					dateFormatArray: ['-', '-', ' ', ':', ':']
					},
					orderListHeight: 300,
					orderLiHeight: 260,
					orderList: [],
					tdWidth: [50, 60, 125, 125, 125, 125, 125,125],
			}
		},
		components: {
			QSpicker,
			uniIcon,
		},
		onLoad() {
			setTimeout(() => {
				this.showCalendar = true
			}, 350);
			this.getClientList();
			this.GetOperatorMessage();
			this.GetStoreMessage();
			// this.open(1);
			// this.open(2)
		},
		computed: {
			tdAllWidth() {
				var tdAllWidth = 0;
				this.tdWidth.forEach(item => {
					tdAllWidth += parseFloat(item);
				});
				tdAllWidth += this.tdWidth.length - 1;
				return tdAllWidth;
			}
		},
		//页面加载完成获取高度
		onReady(){
			var that = this
			uni.getSystemInfo({
			　　success: function(res) { // res - 各种参数
			　	let main = uni.createSelectorQuery().select(".cg-main");
			　　　  　main.boundingClientRect(function(data) { //data - 各种参数
			// 　　　  　console.log("元素的高度"+data.height)  // 获取元素宽度
			        console.log(data)
					 // 剩余的高度
					 // orderListHeight: 300,
					 // orderLiHeight: 260,
					 that.orderListHeight = res.windowHeight - data.height;
					 that.orderLiHeight = (res.windowHeight - data.height) - 40;
					 // that.orderListHeight = res.windowHeight - (6*37);
					 // that.orderLiHeight = (res.windowHeight - (6*37)) - 40;
					 console.log('剩余的高度')
					 console.log(that.orderListHeight)
					 console.log('表格内容的高度')
					 console.log(that.orderLiHeight)
					 // 表格内容的高度
					 console.log((res.windowHeight - data.height) - 40)
			　　    }).exec()
			       }
			});
		},
		created(){
			let date = new Date();
			this.BillDate = GetApi.splitdate(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate());
			//初始化默认赋值今天日期
			this.timeData.fulldate = this.BillDate
			this.timeData1.fulldate = this.BillDate
		},
		onPageScroll(res){
			// console.log(res.scrollTop);//距离页面顶部距离
			var scrolls = res.scrollTop
			var that = this
			uni.getSystemInfo({
			　　success: function(res) { // res - 各种参数
			// 　　   console.log(res.windowWidth); // 屏幕的宽度 
			         // console.log('返回顶部出现的位置'+(res.screenHeight+res.screenHeight/3))
			// 　　    let info = uni.createSelectorQuery().select(".sticky");
			// 　　　  　info.boundingClientRect(function(data) { //data - 各种参数
			// // 　　　  　console.log("元素的高度"+data.height)  // 获取元素宽度
			//          if(scrolls>data.height){
			// 			 // console.log('大于了')
						
			// 			 that.setfixeds = true
			// 		 }else{
			// 			 that.setfixeds = false
			// 		 }
					 
					 
			// 　　    }).exec()
			that.istop = scrolls>(res.screenHeight+res.screenHeight/2)?true:false
			       }
			});
			
		},
		methods: {
			//跳转到明细
		checktr:function(e){
				let Detailid =  this.tableList[e]['BillID'];
				let BillNo = this.tableList[e]['BillNo'];
				uni.navigateTo({
				    url: '../../Purchasereturn/select_children/selectdetail/selectdetail?id='+Detailid+'&BillNo='+BillNo
				});
			},
			//多选
			radiocheck:function(evt){
				// this.ischeck = evt
				this.tableList[evt]["ischeck"] = this.tableList[evt]["ischeck"] == true ? false :true
				// console.log(this.tableList)
				// console.log(evt)
				//如果全部选中了，改变全选
				for(let j in this.tableList){
					if(this.tableList[j]["ischeck"] !=false){
						this.selectcheckall = 2
					}else{
						this.selectcheckall = 1
					}
				}
			},
			// 选择
			electGoods:function(){
				//默认选中第一个
				var check = []
				for(let i in this.tableList){
					// console.log(i)
					// console.log(this.tableList[i]["ischeck"])
					if(this.tableList[i]["ischeck"] == true){
				       check.push(this.tableList[i])
					}
				}
				if(check == "" || check.length == 0){
					GetApi.showTip("请选择单据!");
					return
				}
				var that = this
				if(check.length>=2){
					GetApi.showConfirm("已经选中多张(默认选择第一张单据),是否继续？", function(state,) {
						if (state) {
						   that.returnevent(check[0])
						}
					})
				}else{
					this.returnevent(check[0])
				}
			},
			clicktop:function(){
							 uni.pageScrollTo({
							 scrollTop: 0,
							 duration: 300
							 });
							 console.log('这是一个点击事件')
							 console.log('打印打印')
			},
			returnevent:function(e){
				this.$eventHub.$emit('psfire',e);//携带参数返回
				this.$eventHub.$off('psfire');
				uni.navigateBack({
					delta:1
				})
			},
			open(name, type) {
				this.isdata = type;//赋值给isdata用于判断是开始日期还是结束日期
				this.$refs[name].show();
				this.dateName = name;
			},
			confirm(res) {
				var data = GetApi.splitdate(res.data);//处理的日期
				console.log(data)
				// 1是开始日期 2是结束日期
				if(this.isdata == 0){
					// console.log(e)
					this.timeData.fulldate = data
				}else if(this.isdata == 1){
					this.timeData1.fulldate = data
				}
				this.$refs[this.dateName].hide();
			},
			showQSPicker(res) {
				console.log(res);
			},
			hideQSPicker(res) {
			
			},
			//是否展开
			homeunfolds:function(e){
				if(this.homeunfold == e){
					this.homeunfold = -1
				}else{
					this.homeunfold = e
				}
			},
			//全选
			selectcheck:function(){
				// selectcheckall
				for(let j in this.tableList){
					this.tableList[j]["ischeck"] = this.selectcheckall == 1 ? true :false
				}
				this.selectcheckall = this.selectcheckall == 1?2:1
			},
			// 删除
			DelectGoods:function(){
				// 找出选中删除的id
				var delid = null;
				this.delbillid = []
				for(let i in this.tableList){
					console.log(i)
					console.log(this.tableList[i]["ischeck"])
					
					if(this.tableList[i]["ischeck"] == true){
						this.delbillid.push(this.tableList[i]["BillID"])
			           // delid+=this.tableList[i]["BillID"]+','
					}
					
					
				}
				if(this.delbillid.length == 0 ||this.delbillid==""){
					GetApi.showTip("请选择要删除的单据!");
					return
				}
				var that = this;
				GetApi.showConfirm("删除单据将无法恢复,是否删除？", function(state,) {
					if (state) {
						that.tableList = [] //先清空原来的数据
						let ClientID = uni.getStorageSync("UserCode");
						let CreateName = uni.getStorageSync("UserName");
						let data = {
							BillType:3,
							Database:'FastApp',
							BillID:that.delbillid.join(','),
						};
						
						GetApi.Delete_Bill(data,function(res){
							  if(res.state){
								  console.log(res)
								   if(res.data.ErrorMsg=="获取登录信息失败"){
									   GetApi.showTip("登录超时");
								   }else if(res.data.ErrorMsg!=""){
									   GetApi.showTip(res.data.ErrorMsg);
								   }else{
									     GetApi.showTip(res.data.TipsMsg);
								   }
							  }else{
								  GetApi.showTip("服务器错误!");
							  }
						});
					}})
					
					
			},
			back:function(){
				this.Detail = false
			},
			// 选中的供应商
			checkuser:function(e){
				this.checkedClientList = this.ClientList[e]
				// this.checklist = e
				this.isshow=false
				console.log('打印的参数')
				console.log(this.checkedClientList)
			},
			// 选中的仓库
			checkware:function(e){
				this.checkedwarehouse = this.StoreList[e]
				// this.checklist = e
				this.modalName=null
				console.log('打印的参数')
				console.log(this.checkedwarehouse)
			},
			// 选中的业务员
			checksale:function(e){
				this.checksalesman = this.OperatorList[e]
				// this.checklist = e
				this.modalName=null
				console.log('打印的参数')
				console.log(this.checksalesman)
			},
			//获取更多商品信息
			lookGoodsInfo(index){
				if(this.selectLookMore == index){
					this.selectLookMore = -1;
				}else{
					this.selectLookMore = index;
				}
			},
			//选择供应商
			supplier:function(){
				var that = this
				this.$eventHub.$on('clientListen', function (data) {
				      console.log('返回的参数')
					  // JSON.parse(data)
					  // var checkd = JSON.parse(data)
					  // that.checkdata.ClientID = checkd["ClientID"]
					  // that.checkdata.BName = checkd["ClientName"]
					  // console.log(JSON.parse(data))
					  // console.log(that.checkdata.ClientID)
					  // console.log(that.checkdata.BName)
					  that.checkedClientList = JSON.parse(data)
					  
					that.$eventHub.$off('clientListen');
					});
				uni.navigateTo({
					// pages/clientSelect/clientSelect
				    url: '../../clientSelect/clientSelect?isClient=1'
				});
			},
            clickopen:function(evt,msg){
            	var that = this;	
            	console.log(evt)
            	this.listshow = Number(evt);
            	that.listcode = msg;
            	that.modalName = 'Modal'
            },                                                                 
			
			
			//获取供应商列表
			getClientList(){
				let data = {
					Filter:"IsClient<>1"
				}
				this.picker = [];
				var that = this;
				GetApi.GetClientPurMessage(data,function(res){
					console.log(res)
					  if(res.state){
						   if(res.data.ErrorMsg=="获取登录信息失败"){
							   GetApi.showTip("登录超时");
						   }else if(res.data.ErrorMsg!=""){
							   GetApi.showTip(res.data.ErrorMsg);
						   }else{
							   let responseData = res.data.ResultMsg;
							   that.ClientList  = responseData;
						   }
					  }else{
						  
					  }
				});
			},
			//获取业务员列表
			GetOperatorMessage(){
				let data = {
					Filter:""
				}
				
				var that = this;
				GetApi.GetOperatorMessage(data,function(res){
					  if(res.state){
						   if(res.data.ErrorMsg=="获取登录信息失败"){
							   GetApi.showTip("登录超时");
						   }else if(res.data.ErrorMsg!=""){
							   GetApi.showTip(res.data.ErrorMsg);
						   }else{	  
							   that.OperatorList = res.data.ResultMsg;

						   }
					  }else{
						  
					  }
				});
			},
			SelectStockNum(GoodsID){
				if(this.StoreList.length==0){
					uni.showToast({
						title:"请先选择仓库"
					});
					return;
				};
				
				let StroeID = this.StoreList[this.index2].StoreID;
			    let data = {
					StoreID:StroeID,
					GoodsID:GoodsID,
					BillName:"采购入库单"
				};
				var _this = this;
				GetApi.SelectStockNum(data,(res)=>{
					 if(res.data.ErrorMsg == "获取登录信息失败"){
						 
					 }else if(res.data.ErrorMsg !="" ){
						 GetApi.showTip(res.data.ErrorMsg);
					 }else{
						 _this.GoodsStorm = res.data.ResultMsg;
					 }
				});
			},

			AddListen(){
				var _this = this;
				this.$eventHub.$on('fire', function(data) {
					let GoodsItem = JSON.parse(data);
					_this.NowSelectGoods = GoodsItem;
					_this.SelectStockNum(GoodsItem.GoodsID)
					_this.$eventHub.$off('fire');
				});
			},
			//获取仓库
			GetStoreMessage(){
				var that = this;
				let data = {
					Filter:""
				}
				GetApi.GetStoreMessage(data,function(res){
					  if(res.state){
						   if(res.data.ErrorMsg=="获取登录信息失败"){
							   GetApi.showTip("登录超时");
						   }else if(res.data.ErrorMsg!=""){
							   GetApi.showTip(res.data.ErrorMsg);
						   }else{
							   that.StoreList = res.data.ResultMsg;
							 
						   }
					  }else{
						  
					  }
				});
			},
			xiala(e) {
				var i = e.currentTarget.dataset.findex;
				console.log(i)

			},
		
			gogoodlist() {
				this.AddListen();
				uni.navigateTo({
					url: "../goodList/goodList?type=1"
				})
			},
			showModal(e) {
				console.log(1111)
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				console.log(222)
				this.modalName = null
			},
			choosesunit(e) {
				console.log(e)
				var unit = e.currentTarget.dataset.unit
				this.unitselected = unit
				this.modalName = null
			},
			//查询
			SelBill(){
				
			    console.log('单据编号')
				console.log(this.BillNo)
			    if(this.timeData.fulldate == "" || this.timeData.fulldate==undefined){
					GetApi.showTip("单据时间不能为空")
				}else if(this.timeData1.fulldate == "" || this.timeData1.fulldate==undefined){
					GetApi.showTip("结束时间不能为空")
				}
				else{
					var that = this;
					that.tableList = [] //先清空原来的数据
					let ClientID = uni.getStorageSync("UserCode");
					let CreateName = uni.getStorageSync("UserName");
					// // 选中的供应商
					// checkedClientList:[],
					// //选中的仓库
					// checkedwarehouse:[],
					// //选中的业务员
					// checksalesman:[],
					
					console.log(this.checkedClientList.ClientID)
					let isnullBillNo =  this.BillNo==""?'':  ' and '+"[BillNo] like '%"+this.BillNo+"%'";//如果为空则不传
					let isnullClientID =  this.checkedClientList == "" ||this.checkedClientList ==undefined ?'': ' and '+"ClientID='"+this.checkedClientList.ClientID+"'";
					let isnullEmpID =  this.checksalesman == "" || this.checksalesman ==undefined?'': ' and '+"EmpID='"+this.checksalesman.OperatorID+"'";
					let isnullStoreID =  this.checkedwarehouse == "" ||this.checkedwarehouse==undefined?'': ' and '+"StoreID='"+this.checkedwarehouse.StoreID+"'";
					
					let data = {
						BillType:3,
						Database:'FastApp',
						Filter:"[BillTime]>='"+that.timeData.fulldate  +"'●and●[BillTime]<='"+that.timeData1.fulldate+"'"
						+"●and●[state]='0'"+ isnullBillNo+ isnullClientID+isnullEmpID+isnullStoreID,
						
						// +' and '+
						// "ClientID="+this.ClientList[this.index]['ClientID']+  ' and ' + "StoreID="+this.StoreList[this.index2]['StoreID']
						// + ' and ' + "EmpID="+this.OperatorList[this.index1]['OperatorID'] +' and '+ "BillNo="+this.BillNo
						
					};
					GetApi.Select_Bill_Master(data,function(res){
						  if(res.state){
							   if(res.data.ErrorMsg=="获取登录信息失败"){
								   GetApi.showTip("登录超时");
							   }else if(res.data.ErrorMsg!=""){
								   GetApi.showTip(res.data.ErrorMsg);
							   }else if(res.data.TipsMsg == "OK" && res.data.ResultMsg == ""){
								   GetApi.showTip("查无数据");

							   }else{
								     console.log(res.data.ResultMsg);
								   	// that.tableList = res.data.ResultMsg
									for(let i in res.data.ResultMsg){
										console.log(i)
										res.data.ResultMsg[i]["ischeck"] = false;//赋值默认不选中
										console.log(res.data.ResultMsg[i])
									}
									console.log('这是一个打印')
									console.log(res.data.ResultMsg)
									that.tableList = res.data.ResultMsg
							   }
						  }else{
							  GetApi.showTip("服务器错误!");
						  }
					});
				}
			},
			// 主界面切换
			swits:function(){
				this.switrs = this.switrs == 1?2:1
			},
			  //是否全选  点击后改变状态
			ischecka:function(){
						if(this.ischeckall == false){
							this.ischeckall = true
						}else{
							this.ischeckall = false
						}
							
			 },
			 // 日期截取
			 timesubstr:function(e){
				 return e == ""|| e == undefined?e:e.substring(0,10)
			 },
			 //保留两位小数
			 toFix:function(evt){
				 if(evt == ""|| evt==undefined){
					 return evt
				 }
				 evt = parseFloat(evt);
				 return evt.toFixed(2)//此处2为保留两位小数
			 },
			 onNavigationBarButtonTap(e) {
			 	const index = e.index;
			 	console.log(index);
			 	if (index === 0) {
			        this.swits()
			 		} 
			 },
		}

	}
</script>

<style lang="scss">
	@import url("/select_children.css");
	page {
		background-color: #EEEEEE;
		padding-bottom: 0upx;
		height: 100%;
	}
	.header {
		position: fixed;
		z-index: 100;
		width: 100%;
		background: #fff;
		height: 45px;
	}
     .background{
		 background-color: #fff;
	 }
	.stop {
		background-color: rgb(96, 188, 204) !important;
	}

	.text-color {
		color: rgba(124, 170, 216, 1);
	}

	.f-size {
		font-size: 16px;
		
	}

	.main {
		/* padding-top: 55px; */
		background: #EEEEEE;
	}

	.inpt1 {
		width: 100%;
		text-align: right;
		align-items: center;
		display: flex;
	}

	/* .detail-box {
		padding-top: 40px;
	} */

	view {
		font-size: 28upx;
		line-height: inherit
	}

	.example {
		padding: 0 30upx 30upx
	}

	.example-title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 32upx;
		color: #464e52;
		padding: 30upx 30upx 30upx 50upx;
		margin-top: 20upx;
		position: relative;
		background-color: #fdfdfd;
		border-bottom: 1px #f5f5f5 solid
	}

	.example-title__after {
		position: relative;
		color: #031e3c
	}

	.example-title:after {
		content: '';
		position: absolute;
		left: 30upx;
		margin: auto;
		top: 0;
		bottom: 0;
		width: 6upx;
		height: 32upx;
		background-color: #ccc
	}

	.example .example-title {
		margin: 40upx 0
	}

	.example-body {
		padding: 30upx;
		background: #fff
	}

	.example-info {
		padding: 30upx;
		color: #3b4144;
		background: #fff
	}

	.calendar-content {
		padding-bottom: 100upx;
		font-size: 26upx;
	}

	.calendar-content-active {
		padding-bottom: 450upx;
	}

	.calendar-tags-group {
		display: flex;
		flex-direction: column;
		flex-wrap: wrap;
		justify-content: space-between;
	}

	.calendar-tags {
		width: 100%;
		box-sizing: border-box;
	}

	.calendar-tags-item {
		padding: 20upx 20upx;
		border: 1px rgba(0, 0, 0, 0.2) solid;
		color: #333;
		border-radius: 10upx;
		text-align: center;
		margin: 10upx;
		background: #f8f8f8;
	}

	.calendar-tags-item:active {
		background: #f8f8f8;
	}

	.checked .calendar-tags-item {
		background: rgb(0, 122, 255);
		color: #fff;
		border: 1px rgba(0, 0, 0, 0.1) solid;
	}

	.calendar-button {
		font-weight: bold;
		font-size: 32upx;
	}

	.calendar-button-groups {
		position: absolute;
		width: 100%;
		bottom: 0;
		display: flex;
	}

	.calendar-button-confirm {
		width: 50%;
		margin: 10upx;
		border: 1px #eee solid;
		font-size: 32upx;
	}

	.calendar-button-confirm:after {
		border: none;
	}

	.calendar-box {
		position: fixed;
		bottom: 0;
		background: #fff;
		color: #444;
		line-height: 1.5;
		width: 100%;
		transition: all 0.3s;
		transform: translateY(320upx);
		/* background: #f5f5f5; */
	}

	.calendar-active {
		transform: translateY(0);
	}

	.calendar-info-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20upx 30upx;
		padding-left: 0;
		border-top: 1px #eee solid;
		border-bottom: 1px #eee solid;
	}

	.calendar-title {
		/* height: 80upx; */
		font-weight: bold;
		color: #666;
		font-size: 32upx;
		border-left: 2px #0d9ebb solid;
		padding-left: 20upx;
		margin: 0 20upx;
	}

	.calendar-info {
		overflow-y: scroll;
		height: 260upx;
		padding: 30upx 30upx;
	}

	/*搜索*/
	/* .goodContainer{
		flex: 1;
		margin-top: 60px;
		padding-bottom: 55px;
	} */
	.searchInput {
		width: 100%;
		height: 40px;
		line-height: 40px;
		background: #FFF;
		display: flex;
		flex-direction: row;
	
		background: #FFF;
		z-index: 999;
	}

	.searchInput .goodType {
		background: #f1f2f7;
		border-radius: 20px;
		height: 28px;
		line-height: 28px;
		color: #9699a2;
		padding-left: 10px;
		padding-right: 10px;
		font-size: 12px;
		margin-top: 6px;
		margin-left: 10px;
	}

	.searchInput .goodFilter {
		flex: 1;
		display: flex;
		background: #eff2fb;
		border-radius: 20px;
		height: 30px;
		line-height: 30px;
		margin-top: 6px;
		box-sizing: border-box;
		margin-left: 10px;
		margin-right: 5px;
	}

	.searchInput .goodFilter .searchOption {
		flex: 1;
		height: 28px;
		line-height: 28px;
		font-size: 28upx;
		color: #9699a2;
	}

	.searchInput .searchOptions {
		width: 70px;
		height: 40px;
		display: flex;
		flex-direction: row;
		padding-top: 7.5px;
	}

	.searchInput .searchOptions .giveSong {
		width: 25px;
		height: 25px;
		/* background: url(../../static/addGoods.png) no-repeat; */
		padding: 0px;
	}

	.searchInput .searchOptions .getPicture {
		width: 25px;
		height: 25px;
		background: url(../../../static/sm.png) no-repeat;
		padding: 0px;
	}

	.allGoodsType {
		width: 100%;
		height: calc(100% - 50px);
		background: #FFF;
		position: fixed;
		top: 90px;
		left: 0px;
		z-index: 99999;
	}

	.allGoodsType .typeTitle {
		width: 100%;
		height: 40px;
		line-height: 40px;
		color: #000;
		padding-left: 15px;
		border-bottom: 1px solid #ebebeb;
		box-sizing: border-box;
		padding-right: 15px;
		font-size: 32upx;
	}

	.allGoodsType .typeTitle .pulljt {
		display: inline-block;
		float: right;
		transform: rotate(90deg);
		-ms-transform: rotate(90deg);
		/* IE 9 */
		-moz-transform: rotate(90deg);
		/* Firefox */
		-webkit-transform: rotate(90deg);
		/* Safari 和 Chrome */
		-o-transform: rotate(90deg);
	}

	.allGoodsType .typeItem {
		display: block;
		width: 100%;
		height: 40px;
		line-height: 40px;
		border-bottom: 1px solid #ebebeb;
		margin-left: 15px;
		padding-left: 5px;
		font-size: 28upx;

	}


	/*这个定义动画情况，以及存在时的样式，这个样式会覆盖class里的样式*/
	.mytran-transition {
		transition: all 0.3s ease;
		opacity: 1;
	}

	/* .mytran-enter 定义进入的开始状态 */
	/* .mytran-leave 定义离开的结束状态 */
	.mytran-enter,
	.mytran-leave {
		height: 0;
	}

	/*弹窗*/
	.ls-box {
		font-size: 16px;
		padding: 5px 0;
		border-bottom: 1rpx #E1D7F0 solid;
		color: #24292E;
	}

	.bg-ls {
		background-color: rgba(33, 167, 191, 1);
		position: fixed;
		width: inherit;
		height: 50px;
		z-index: 100;
	}

	.ls-main {
		max-height: 70%;
	}

	.ls-contain {
		padding-top: 50px;
		height: inherit;
	}
	
	
	/**选取的商品列表**/
	.selectGoodsList{
		width: 100%;
		display: table;
		padding-top: 20upx;
		padding-bottom: 20upx;
	}
	.selectGoodsList .goodListItem{
		width: 90%;
		border-radius: 15upx;
		margin: auto;
		overflow: hidden;
		background: #FFF;
		padding-bottom: 15upx;
		margin-bottom: 15upx;
		height: 38px;
	} 
	.selectGoodsList .goodListItem.lookMore{
		display: table;
		}
	.selectGoodsList .goodListItem .goodsTitle{
		 width: 100%;
		 height: 80upx;
		 line-height: 80upx;
		 background: #60bccc;
		 box-sizing: border-box;
	     font-size: 32upx;
		 padding:0upx 15upx;
		 color:#FFF;
		 position: relative;
	}
	.selectGoodsList .goodListItem .goodsTitle button{
		position: absolute;
		height: 50upx;
		line-height: 50upx;
		font-size: 24upx;
		text-align: center;
		border-radius: 30upx;
		border:none;
		background: #FFF;
		right: 15upx;
		top:15upx;
		color: #5d5d5d;
	}
	.selectGoodsList .goodListItem .goods-itemWrap{
		 width: 100%;
		 box-sizing: border-box;
		 padding:0upx 15upx;
		 height: 60upx;
		 line-height: 60upx;
		 display: flex;
	}
	.selectGoodsList .goodListItem .goods-itemWrap text{
		flex: 1;
	}
	.btn_width{
		width: 23%;
	}
	.btn_color{
		background-color: #747182 !important;;
	}
	//表格单据
	.orderList {
		width: 100%;
		overflow: auto;
		box-sizing: border-box;
	
		text {
			float: left;
			text-align: center;
			box-sizing: border-box;
			height: 40px;
			line-height: 40px;
			border-right: 1px solid #CCC;
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
	
			&:last-child {
				border: none;
			}
		}
	
		.orderNav {
			height: 40px;
			line-height: 40px;
			box-sizing: border-box;
			overflow: hidden;
			border-top: 1px solid #CCC;
			border-left: 1px solid #FFF;
			background: #FFF;
	
		}
	
		.orderLi {
	
			background: #ebebeb;
			overflow: auto;
	
			.orderItem {
				height: 40px;
				line-height: 40px;
				width: 100%;
				border: 1px solid #ebebeb;
				box-sizing: border-box;
				display: table;
				border-bottom: 1px solid #CCCCCC;
	
				view {
					display: inline-block;
					height: 100%;
					line-height: 35px;
					float: left;
					text-align: center;
					border-right: 1px solid #CCC;
					box-sizing: border-box;
					padding-top: 5upx;
					padding-bottom: 5upx;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
	
					image {
						width: 60px;
						margin: auto;
						display: table;
					}
	
					&:last-child {
						border: none;
					}
	
				}
			}
		}
	
		.allPrice {
			@extend .orderNav;
			background: rgba(124, 170, 216, 1);
			color: #FFF;
		}
	}
	
</style>
